﻿/*------------------------------------------------------------------------

GATE.HPP v3.0.1

Copyright 楊志賢 CxxlMan, 2004 - 2011
All Rights Reserved

適用於單一物件，即作為單一物件的屬性之用
------------------------------------------------------------------------*/


#if !defined(__GATE_HPP_CxxlMan)
#define __GATE_HPP_CxxlMan

#include "DLLDEF.HPP"

#if defined(_CXXLCOMMON_DLLEXPORT)
#define CXXLCOMMON_DLLEXPORT CXXL_DLLEXPORT
#else
#define CXXLCOMMON_DLLEXPORT CXXL_DLLIMPORT
#endif


namespace CxxlMan
{

// 閘門的類別介面
class CXXLCOMMON_DLLEXPORT IGateBase
{
protected:
  IGateBase(void){}
public:
  virtual ~IGateBase(void){}
  virtual void cxxlFASTCALL Wait(void) const = 0;
  virtual void cxxlFASTCALL Signal(void) const  = 0;
};

// 依平台取得 IGateBase 的實作
class CXXLCOMMON_DLLEXPORT Gate
{
  IGateBase *Imp;
public:
  Gate(void);         // Constructor
  ~Gate(void)         // Destructor
  {
    delete Imp;
  }
  void cxxlFASTCALL Wait(void) const     // 等待事件信號，通過會自動關門
  {
    Imp->Wait();
  }
  void cxxlFASTCALL Signal(void) const   // 事件信號通知(開門)，讓 Wait() 返回
  {
    Imp->Signal();
  }
};


}   /* namespace CxxlMan */
#endif
